﻿
using System;
using GameFramework.Event;
using GameFramework.Fsm;
using GameFramework.Procedure;
using UnityEngine;
using UnityGameFramework.Runtime;
/// <summary>
/// Pve对抗
/// </summary>
public class PveAgainstProcedure : GameBaseProcedure
{
    protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);
        Log.Info("Pve对抗");
        
        EntityInst.Event.Subscribe(LoadDataTableSuccessEventArgs.EventId,OnDatatbleLoadSuccess);
        
        EntityInst.Table.LoadDataTable("Audio","Assets/RuntimeResources/DataTables/Audio.txt",this);
    }

    private void OnDatatbleLoadSuccess(object sender, GameEventArgs args)
    {
        LoadDataTableSuccessEventArgs ne = args as LoadDataTableSuccessEventArgs;
        if (ne.UserData != this)
            return;

        var allRows = EntityInst.Table.GetDataTable<DTAudio>().GetAllDataRows();

        foreach (var row in allRows)
        {
            Debug.Log($"datatable info , row = {row.Id},{row.AssetName},{row.Volume}");
        }
        
        Log.Info($"load table success, table name = {ne.DataTableAssetName}");
    }
}